package lab02.test03;



//定义学生的类
public class Student {
    float computergrade;
    float mathgrade;
    float Englishgrade;

    public Student(){}

    public Student(float computergrade, float mathgrade, float English) {
        this.computergrade = computergrade;
        this.Englishgrade = Englishgrade;
        this.mathgrade = mathgrade;
    }
    public void setComputerGrade(float computergrade) {
        this.computergrade = computergrade;
    }

    public float getComputerGrade() {
        return computergrade;
    }

    public void setEnglishGrade(float Englishgrade) {
        Englishgrade =  Englishgrade;
    }

    public float getEnglishGrade() {
        return Englishgrade;
    }

    public void setMathGrade(float mathgrade) {
        this.mathgrade = mathgrade;
    }

    public float getMathGrade() {
        return mathgrade;
    }
    //计算总分


    public double allGrade() {
        return (computergrade + Englishgrade + mathgrade);
    }

    //计算平均分

    public double avergeGrade() {
        return  (computergrade + Englishgrade + mathgrade) / 3;

    }

    //获取最高分
    public double maxGrade() {
       float max = computergrade;
        if (max < Englishgrade) {
            max = Englishgrade;
            if (max < mathgrade) {
                max = mathgrade;
            }
        }
        return max;
    }

    //获取最低分
    public double minGrade() {
       float min = computergrade;
        if (min > Englishgrade) {
            min = Englishgrade;
            if (min > mathgrade) {
                min = mathgrade;
            }
        }

        return min;
    }
    public void print(){
        System.out.println("该学生数学成绩"+mathgrade);
        System.out.println("该学生英语成绩"+Englishgrade);
        System.out.println("该学生计算机成绩"+computergrade);

        System.out.println("该学生总成绩"+allGrade());
        System.out.println("该学生平均成绩"+avergeGrade());
        System.out.println("该学生最高成绩"+maxGrade());
        System.out.println("该学生最低成绩"+minGrade());
    }
}

